﻿#include <iostream>
#include "string.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <iostream>
#include "string.h"
#include <bitset>
#include "video_mgr.h"
#include <mutex>
#include "task/task_mgr.h"

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
 
#include <getopt.h> 
#include <errno.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>

std::mutex serial_mx;
std::mutex serial_reade_mx;
std::mutex serial_status_mx;

static bool g_irisTask = false; //iris是否打开

using namespace std;

mv::VideoMgr::VideoMgr()
{

}
mv::VideoMgr::VideoMgr(const int iDirection)
{

}

mv::VideoMgr::~VideoMgr()
{

}

int mv::VideoMgr::carWindowProcessCtrl(bool bStart) {
	if (bStart) {
		return startCarWindowProcess();
	} else {
		return stopCarWindowProcess();
	}
}

int mv::VideoMgr::irisCameraPreviewCtrl(bool bOpen) {
	if (bOpen) {
		return openIrisCamera();
	} else {
		return closeIrisCamera();
	}
}

bool mv::VideoMgr::startCarWindowProcess() {
	if (!m_bCarWindowState) {
		m_bCarWindowState = true;
		//TODO线程同步处理g_task里的数据流
	}
	return true;
}

bool mv::VideoMgr::stopCarWindowProcess() {
	if (m_bCarWindowState) {
		m_bCarWindowState = false;
		//TODO硬件检测到车窗暂停线程,算法检测到车窗暂停线程
	}
	return true;
}

bool mv::VideoMgr::openIrisCamera() {
	//打开虹膜预览

	g_irisTask = true;
	return true;
}

bool mv::VideoMgr::closeIrisCamera() {
	//关闭虹膜预览

	g_irisTask = false;
	return true;
}
